﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace OznerOA.Common
{
    public class ThreadHelper
    {
        private static List<Thread> Threads = new List<Thread>();
        public static Thread StartNewThread(ThreadStart start,bool background)
        {
            Thread thread = new Thread(start);
            Threads.Add(thread);
            thread.IsBackground = background;
            thread.Start();
            return thread;
        }
        public static Thread StartNewThread(ThreadStart start)
        {
            return StartNewThread(start, true);
        }
        public static Thread StartNewThread(ParameterizedThreadStart start, bool background)
        {
            Thread thread = new Thread(start);
            thread.IsBackground = background;
            Threads.Add(thread);
            thread.Start();
            return thread;
        }
        public static void AbortAllThread()
        {
            foreach(Thread thread in Threads)
            {
                thread.Abort();
            }
        }
    }
}
